import org.w3c.dom.Node;

import java.util.*;

public class Test {

    class Node {
        int val;
        Node next;
        Node random;

        public Node(int val) {
            this.val = val;
            this.next = null;
            this.random = null;
        }
    }
        //随机链表的复制
    public Node copyRandomList(Node head) {
        Map<Node, Node> map = new HashMap<>();

        //第一次遍历
        Node cur = head;
        while (cur != null) {
            Node node = new Node(cur.val);
            map.put(cur, node);
            cur = cur.next;
        }
        cur = head;

        //第二次遍历
        Node curN = cur;
        while (curN != null) {
            map.get(curN).next = map.get(curN.next);
            map.get(curN).random = map.get(curN.random);
            curN = curN.next;
        }
        return map.get(cur);
    }

    //坏键盘打字
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String s1 = in.nextLine();
            String s2 = in.nextLine();
            func(s1, s2);
        }
    }

    public static void func(String s1, String s2) {
        String str1 = s1.toUpperCase();
        String str2 = s2.toUpperCase();

        Set<Character> set = new HashSet<>();
        for (int i = 0; i < str2.length(); i++) {
            if (!set.contains(str2.charAt(i))) {
                set.add(str2.charAt(i));
            }
        }

        Set<Character> setk = new HashSet<>();
        for (int i = 0; i < str1.length(); i++) {
            if (!set.contains(str1.charAt(i))
                    && !setk.contains(str1.charAt(i))) {
                setk.add(str1.charAt(i));
                System.out.print(str1.charAt(i));
            }
        }
    }


    //宝石和石头
    public int numJewelsInStones(String jewels, String stones) {
        Set<Character> set = new HashSet<>();
        //第一次遍历，确定宝石类型
        for(int i = 0;i < jewels.length();i++){
            if(!set.contains(jewels.charAt(i))){
                set.add(jewels.charAt(i));
            }
        }

        //第二次遍历，确定石头中的宝石
        int count = 0;
        for(int i = 0; i < stones.length();i++){
            if(set.contains(stones.charAt(i))){
                count++;
            }
        }
        return count;
    }


    //只出现一次的数字
    public int singleNumber(int[] nums) {
        Set<Integer> set = new HashSet<>();
        for(int i = 0;i < nums.length; i++){
            if(!set.contains(nums[i])){
                set.add(nums[i]);
            }else{
                set.remove(nums[i]);
            }
        }
        for(int i = 0; i < nums.length;i++){
            if(set.contains(nums[i])){
                return nums[i];
            }
        }
        return -1;
    }


}
